

******************************************************************************************************************
************************* 4 December 2024 ******************************************************** Author TS *****
********** Do-file ***********************************************************************************************
**** Effects of Popular Legitimacy on International Organizations: An Elite Survey Experiment ********************
********** NOTE: please adapt syntax to your working directory ***** Replace: /Users/thomassommerer/Dropbox/JoP/ *
*******************  STATA 18.0 SE MAC ***************************************************************************


************************ Overview **************

***** 1. T-tests & Export of Stata output ******
***** 2. Editing of the dataset based on t-tests
***** 3. Figures 1-5, main text  ***************
***** 4. Appendix Figures B1-B7 & Tables *******

************************************************





**************************************************************
******* 1. T-tests and export of Stata output ****************
**************************************************************


*************************+ Note: results including p-values stored in "EffectsofLegitimacy_ttest.dta", see  below ****

*** T-test for Figure 1

********* Three DVs: Resources, Independence, Authority 

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta", clear
sort id

quietly ttest q23_1_*, by(exp_g)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r1.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_*, by(exp_g)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i1.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_*, by(exp_g)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a1.dta", replace


*** Ttest for Figure 2

********* Three DVs: Resources, Independence, Authority - subsample by pre-treatment confidence in WHO (lowest two categories merged) ***


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_1_res if q18==4 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r2.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_1_res if q18==3 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r3.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_1_res if q18==2 | q18==1 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r4.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_indep if q18==4 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i2.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_indep if q18==3 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i3.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_indep if q18==2 | q18==1 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i4.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_auth if q18==4 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a2.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_auth if q18==3 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a3.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_auth if q18==2 | q18==1 , by(exp_group)
matrix ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a4.dta", replace


***** Ttest for Figure 3 ********************************************
********* Three DVs: Resources, Independence, Authority - subsample by ideology (left/right) ***

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_1_res if ideology==1 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r5.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_1_res if ideology==2 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r6.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_indep if ideology==1 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i5.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_indep if ideology==2 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i6.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_auth if ideology==1 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a5.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_auth if ideology==2 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a6.dta", replace


**** Ttest  Figure B4   **************
*** Composite index based on mean of Resources, Independence, Authority ***

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_123_index, by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Index)
save "/Users/thomassommerer/Dropbox/JoP/ttest_index.dta", replace


**** Ttest Figure B5 ***********************

********* Three DVs: Resources, Independence, Authority - subsample by pre-treatment  attitudes on international cooperation (lowest two categories merged) ***



use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_1_res if q16==4 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r7.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_1_res if q16==3 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r8.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_1_res if q16==2 | q16==1 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Res)
save "/Users/thomassommerer/Dropbox/JoP/ttest_r9.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_indep if q16==4 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i7.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_indep if q16==3 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i8.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_2_indep if q16==2 | q16==1 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Indep)
save "/Users/thomassommerer/Dropbox/JoP/ttest_i9.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_auth if q16==4 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a7.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_auth if q16==3 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a8.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta"
sort id
quietly ttest q23_3_auth if q16==2 | q16==1 , by(exp_group)
matrix  ttest= (r(mu_1),(r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1)))), (r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1)))  , r(p)     ), r(mu_2), (r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2)))), (r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2)))   , r(p)  ) )
clear 
svmat ttest, names(Auth)
save "/Users/thomassommerer/Dropbox/JoP/ttest_a9.dta", replace




*********************************************
***** 2. Editing of the exported dataset ****
*********************************************


********* Integrate multiple result files into common file ***


use "/Users/thomassommerer/Dropbox/JoP/ttest_r1.dta", clear
append using "/Users/thomassommerer/Dropbox/JoP/ttest_r2.dta""/Users/thomassommerer/Dropbox/JoP/ttest_r3.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_r4.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_r5.dta""/Users/thomassommerer/Dropbox/JoP/ttest_r6.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_r7.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_r8.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_r9.dta"
save "/Users/thomassommerer/Dropbox/JoP/ttest_r.dta"

use "/Users/thomassommerer/Dropbox/JoP/ttest_i1.dta", clear
append using "/Users/thomassommerer/Dropbox/JoP/ttest_i2.dta""/Users/thomassommerer/Dropbox/JoP/ttest_i3.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_i4.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_i5.dta""/Users/thomassommerer/Dropbox/JoP/ttest_i6.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_i7.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_i8.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_i9.dta"
save "/Users/thomassommerer/Dropbox/JoP/ttest_i.dta"

use "/Users/thomassommerer/Dropbox/JoP/ttest_a1.dta", clear
append using "/Users/thomassommerer/Dropbox/JoP/ttest_a2.dta""/Users/thomassommerer/Dropbox/JoP/ttest_a3.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_a4.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_a5.dta""/Users/thomassommerer/Dropbox/JoP/ttest_a6.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_a7.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_a8.dta" "/Users/thomassommerer/Dropbox/JoP/ttest_a9.dta"
save "/Users/thomassommerer/Dropbox/JoP/ttest_a.dta"

***

use "/Users/thomassommerer/Dropbox/JoP/ttest_r.dta"
merge 1:1 _n using "/Users/thomassommerer/Dropbox/JoP/ttest_i.dta"
drop _merge
merge 1:1 _n using "/Users/thomassommerer/Dropbox/JoP/ttest_a.dta"
drop _merge
merge 1:1 _n using "/Users/thomassommerer/Dropbox/JoP/ttest_index.dta"
drop _merge
save "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_ttest.dta"


erase "/Users/thomassommerer/Dropbox/JoP/ttest_a.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a1.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a2.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a3.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a4.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a5.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a6.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a7.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a8.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_a9.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i1.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i2.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i3.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i4.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i5.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i6.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i7.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i8.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_i9.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r1.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r2.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r3.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r4.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r5.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r6.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r7.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r8.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_r9.dta"
erase "/Users/thomassommerer/Dropbox/JoP/ttest_index.dta"



**************************************************************
****** Re-organizing the dataset based on ttest output  ******
**** Mean, CIs(95), p value ****

gen id=_n
order id

rename *1 *_mean1
rename *2 *_cilo1
rename *3 *_cihi1
rename *4 *_p1
rename *5 *_mean2
rename *6 *_cilo2
rename *7 *_cihi2
rename *8 *_p2

reshape long Res_mean Res_cilo Res_cihi Res_p Indep_mean Indep_cilo Indep_cihi Indep_p Auth_mean Auth_cilo Auth_cihi Auth_p Index_mean Index_cilo Index_cihi Index_p, i(id) j(treatment)

drop id
gen id=_n
order id

label define Treatment 1 "Strong public support for WHO" 2 "Weak public support for WHO"
label values treatment Treatment

gen figure =.
replace figure =1 if id<3
replace figure =2 if id>2 & id<9
replace figure =3 if id>8 & id<13
replace figure =5 if id>12

label define Figure 1 "Figure 1" 2 "Figure 2" 3 "Figure 3" 5 "Figure B.5"
label values figure Figure

gen subgroup=.

replace subgroup =1 if id<3
replace subgroup =2 if id>2 & id<5
replace subgroup =3 if id>4 & id<7
replace subgroup =4 if id>6 & id<9
replace subgroup =5 if id>8 & id<11
replace subgroup =6 if id>10 & id<13
replace subgroup =7 if id>12 & id<15
replace subgroup =8 if id>14 & id<17
replace subgroup =9 if id>16 & id<19

label define Subgr 1 "All" 2 "High confidence" 3 "Somewhat high confidence" 4 "Low confidence" 5 "Left" 6 "Right" 7 "Fully agree" 8 "Partially agree" 9 "Disagree"

label values subgroup Subgr
order id treat figure subgroup

label define Reform  2 "Partially oppose reform" 3 "Partially support reform" 4 "Fully support reform"
label values  *_mean Reform

save "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_ttest.dta", replace





****************************************************************************************************
****************************************************************************************************
********** 3. Figures 1-5, main text      **********************************************************
****************************************************************************************************
****************************************************************************************************


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_ttest.dta", clear

**** Figure 1 *****


*** Authority 

twoway (scatter Auth_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Auth_cilo Auth_cihi treatment, lcolor(black))if id>0 & id<3, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(medsmall)angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(medsmall) angle(vertical) valuelabel) title(`"Authority"', size(medium) color(black))  legend(off) xsize(2.5) ysize(5) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_1a.gph"


***  Resources
twoway (scatter Res_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Res_cilo Res_cihi treatment, lcolor(black))if id>0 & id<3, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(medsmall)angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(medsmall) angle(vertical) valuelabel) title(`"Resources"', size(medium) color(black)) legend(off) xsize(2.5) ysize(5) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_1b.gph"

*** Independence

twoway (scatter Indep_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Indep_cilo Indep_cihi treatment, lcolor(black))if id>0 & id<3, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(medsmall) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(medsmall) angle(vertical) valuelabel) title(`"Independence"', size(medium) color(black))  legend(off) xsize(2.5) ysize(5) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_1c.gph"


***** Figure 2 Effect of public opinion on support for IO reforms, by level of pre-treatment confidence  ****************

*** Authority 

twoway (scatter Auth_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Auth_cilo Auth_cihi treatment, lcolor(black))if id>2 & id<9, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(vsmall) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(vsmall) angle(vertical) valuelabel nogrid) by(, title(`"Authority"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(vsmall)lcolor(white)) xsize(5.5) ysize(4) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_2a.gph"


***  Resources
 
twoway (scatter Res_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Res_cilo Res_cihi treatment, lcolor(black))if id>2 & id<9, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(vsmall) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(vsmall) angle(vertical) valuelabel nogrid) by(, title(`"Resources"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(vsmall)lcolor(white)) xsize(5.5) ysize(4) plotregion(lcolor(black))
 
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_2b.gph"


*** Independence

 twoway (scatter Indep_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Indep_cilo Indep_cihi treatment, lcolor(black))if id>2 & id<9, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(vsmall) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(vsmall) angle(vertical) valuelabel nogrid) by(, title(`"Independence"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(vsmall)lcolor(white)) xsize(5.5) ysize(4) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_2c.gph"

 
****** Figure 3  Effect of public opinion on support for IO reforms, by ideological orientation  *********************


*** Authority 

twoway (scatter Auth_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Auth_cilo Auth_cihi treatment, lcolor(black))if id>8 & id<13, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(small) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(small) angle(vertical) valuelabel nogrid) by(, title(`"Authority"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(small)lcolor(white)) xsize(4) ysize(5.5) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_3a.gph"

*** Resources

twoway (scatter Res_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Res_cilo Res_cihi treatment, lcolor(black))if id>8 & id<13, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(small) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(small) angle(vertical) valuelabel nogrid) by(, title(`"Resources"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(small)lcolor(white)) xsize(4) ysize(5.5) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_3b.gph"
 

*** Independence

 twoway (scatter Indep_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Indep_cilo Indep_cihi treatment, lcolor(black))if id>8 & id<13, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(small) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(small) angle(vertical) valuelabel nogrid) by(, title(`"Independence"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(small)lcolor(white)) xsize(4) ysize(5.5) plotregion(lcolor(black))

 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_3c.gph"

 
 
 ********* Figure 4  Expected consequences of going against public opinion    ***********
 
 

**** Generate binary version of q29* & q31* merging two positive and two negative categories of original variables
 
 
use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta", clear
 

gen	q29_1_POopp_foreignpol_bin	=	q29_1_POopp_foreignpol 
gen	q29_2_POopp_domestic_bin	=	q29_2_POopp_domestic 
gen	q29_3_POopp_bipartagree_bin	=	q29_3_POopp_bipartagree 
gen	q29_4_POopp_govsupport_bin	=	q29_4_POopp_govsupport
				
gen	q31_1_POsupp_foreignpol_bin	=	q31_1_POsupp_foreignpol
gen	q31_2_POsupp_domestic_bin	=	q31_2_POsupp_domestic
gen	q31_3_POsupp_bipartagree_bin	=	q31_3_POsupp_bipartagree 
gen	q31_4_POsupp_govsupport_bin	=	q31_4_POsupp_govsupport



recode q*bin (1/2=0) (3/4=1)

replace	q29_1_POopp_foreignpol_bin	=	q29_1_POopp_foreignpol_bin	* 100
replace	q29_2_POopp_domestic_bin	=	q29_2_POopp_domestic_bin	* 100
replace	q29_3_POopp_bipartagree_bin	=	q29_3_POopp_bipartagree_bin	* 100
replace	q29_4_POopp_govsupport_bin	=	q29_4_POopp_govsupport_bin	* 100
						
replace	q31_1_POsupp_foreignpol_bin	=	q31_1_POsupp_foreignpol_bin	* 100
replace	q31_2_POsupp_domestic_bin	=	q31_2_POsupp_domestic_bin	* 100
replace	q31_3_POsupp_bipartagree_bin=	q31_3_POsupp_bipartagree_bin	* 100
replace	q31_4_POsupp_govsupport_bin	=	q31_4_POsupp_govsupport_bin	* 100
						

						
						
graph bar (mean) q29_1_POopp_foreignpol_bin q31_1_POsupp_foreignpol_bin, bar(1, fcolor(black) lcolor(black)) bar(2, fcolor(gs11) lcolor(gs11)) bargap(7) ylabel(0(20)100, labsize(small) format(%9.2f) nogrid) title(`"Popular support on other foreign policy issues"', size(small) color(black)) legend(off size(small) position(6)) xsize(5) ysize(7.5) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_4a.gph"


graph bar (mean) q29_2_*bin q31_2*bin, bar(1, fcolor(black) lcolor(black)) bar(2, fcolor(gs11) lcolor(gs11)) bargap(7) ylabel(0(20)100, labsize(small) format(%9.2f) nogrid) title(`"Public support on domestic policy issues"', size(small) color(black)) legend(off size(small) position(6)) xsize(5) ysize(7.5) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_4b.gph"

 graph bar (mean) q29_3*bin q31_3*bin, bar(1, fcolor(black) lcolor(black)) bar(2, fcolor(gs11) lcolor(gs11)) bargap(7) ylabel(0(20)100, labsize(small) format(%9.2f) nogrid) title(`"Unity in parliament on foreign policy issues"', size(small) color(black)) legend(on order(1 "Public opinon against growing power of IO") size(small) position(6)) xsize(5) ysize(7.5) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_4c.gph"

 graph bar (mean) q29_4*bin q31_4*bin, bar(1, fcolor(black) lcolor(black)) bar(2, fcolor(gs11) lcolor(gs11)) bargap(7) ylabel(0(20)100, labsize(small) format(%9.2f) nogrid) title(`"Support for government in public opinion polls"', size(small) color(black)) legend(on order(2 "Public opinon in favor of growing power of IO") size(small) position(6)) xsize(5) ysize(7.5) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_4d.gph"

drop q*_bin

 
save "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta", replace
 

 
 
********* Figure 5 Expected consequences of going against public opinion, by IO. *************************************

 
**** Generate binary version of q33*-variables, merging two positive and two negative categories ****
 
 
use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta", clear
 
gen	q33_1_conseq_EUbin	=	q33_1_conseq_EU		
gen	q33_2_conseq_UNbin	=	q33_2_conseq_UN		
gen	q33_3_conseq_IMFbin	=	q33_3_conseq_IMF		
gen	q33_4_conseq_NATObin	=	q33_4_conseq_NATO		
gen	q33_5_conseq_WHObin	=	q33_5_conseq_WHO		

recode q33*bin (1/2=0) (3/4=1)

replace	q33_1_conseq_EUbin	=	q33_1_conseq_EUbin	* 100
replace	q33_2_conseq_UNbin	=	q33_2_conseq_UNbin	* 100
replace	q33_3_conseq_IMFbin	=	q33_3_conseq_IMFbin	* 100
replace	q33_4_conseq_NATObin	=	q33_4_conseq_NATObin	* 100
replace	q33_5_conseq_WHObin	=	q33_5_conseq_WHObin	*100
		
save "/Users/thomassommerer/Dropbox/JoP/Fig5.dta", replace
		
ci means q33_1*bin
matrix ci= (r(mean), r(lb), r(ub) )
clear 
svmat ci, names(IOmean)
save "/Users/thomassommerer/Dropbox/JoP/Fig5_EU.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/Fig5.dta", clear
ci means q33_2*bin
matrix ci= (r(mean), r(lb), r(ub) )
clear 
svmat ci, names(IOmean)
save "/Users/thomassommerer/Dropbox/JoP/Fig5_UN.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/Fig5.dta", clear
ci means q33_3*bin
matrix ci= (r(mean), r(lb), r(ub) )
clear 
svmat ci, names(IOmean)
save "/Users/thomassommerer/Dropbox/JoP/Fig5_IMF.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/Fig5.dta", clear
ci means q33_4*bin
matrix ci= (r(mean), r(lb), r(ub) )
clear 
svmat ci, names(IOmean)
save "/Users/thomassommerer/Dropbox/JoP/Fig5_NATO.dta", replace

use "/Users/thomassommerer/Dropbox/JoP/Fig5.dta", clear
ci means q33_5*bin
matrix ci= (r(mean), r(lb), r(ub) )
clear 
svmat ci, names(IOmean)
save "/Users/thomassommerer/Dropbox/JoP/Fig5_WHO.dta", replace


use "/Users/thomassommerer/Dropbox/JoP/Fig5_EU.dta", clear
append using "/Users/thomassommerer/Dropbox/JoP/Fig5_IMF.dta" "/Users/thomassommerer/Dropbox/JoP/Fig5_NATO.dta"  "/Users/thomassommerer/Dropbox/JoP/Fig5_UN.dta" "/Users/thomassommerer/Dropbox/JoP/Fig5_WHO.dta"
save "/Users/thomassommerer/Dropbox/JoP/Fig5_IO.dta", replace

erase "/Users/thomassommerer/Dropbox/JoP/Fig5_EU.dta"
erase "/Users/thomassommerer/Dropbox/JoP/Fig5_IMF.dta"
erase "/Users/thomassommerer/Dropbox/JoP/Fig5_NATO.dta"
erase "/Users/thomassommerer/Dropbox/JoP/Fig5_UN.dta"
erase "/Users/thomassommerer/Dropbox/JoP/Fig5_WHO.dta"
erase "/Users/thomassommerer/Dropbox/JoP/Fig5.dta"


use "/Users/thomassommerer/Dropbox/JoP/Fig5_IO.dta", clear

gen IO=_n
order IO

label define io 1 "EU" 2 "IMF" 3 "NATO" 4 "UN" 5 "WHO"
label values IO io

rename IOmean1 IO_mean
rename IOmean2 IO_cilo
rename IOmean3 IO_cihi

twoway (scatter IO_mean IO, mcolor(black) msize(medsmall) msymbol(circle)) (rspike IO_cil IO_cih IO, lcolor(black)) , ytitle(`"Very or fairly large consequences (in %)"') ytitle(, size(small)) yline(50, lwidth(thin) lpattern(dash) lcolor(gs8)) ylabel(0(25)100, labsize(small) angle(horizontal) nogrid) xscale(range(0 6)) xtitle(, size(zero)) xlabel(1(1)5, labsize(small) angle(horizontal) valuelabel nogrid) legend(off) plotregion(lcolor(black) )

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_5.gph", replace
 

 
 
 
****************************************************************************************************
****************************************************************************************************
*********** 4. Figures B.1-B.7 and Tables in Appendix			     *******************************
****************************************************************************************************
****************************************************************************************************

 

****** Figure B.1 Effect of public opinion on support for IO reforms, relative frequencies

use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta", clear
 

graph bar, over(q23_1_r, label(labcolor("black") angle(vertical) labsize(vsmall))) bar(1, fcolor(gs11) lcolor(gs11)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(percent (%)) ytitle(, size(small) color(black)) ylabel(0(20)70, labsize(small) angle(horizontal) nogrid) by(, title(Support/oppose reforms to strengthen WHO: Resources, size(small) color(black)) note(`""', size(zero))) by(, graphregion(fcolor(white) lcolor(white)  ifcolor(white) ilcolor(white)) plotregion(lcolor(white))) by(exp_gr) subtitle(, size(small) color(black) fcolor(white) lcolor(white)) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B1_Resources.gph"



graph bar, over(q23_2_i, label(labcolor("black") angle(vertical) labsize(vsmall))) bar(1, fcolor(gs11) lcolor(gs11)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(percent (%)) ytitle(, size(small) color(black)) ylabel(0(20)70, labsize(small) angle(horizontal) nogrid) by(, title(Support/oppose reforms to strengthen WHO: Independence, size(small) color(black)) note(`""', size(zero))) by(, graphregion(fcolor(white) lcolor(white)  ifcolor(white) ilcolor(white)) plotregion(lcolor(white))) by(exp_gr) subtitle(, size(small) color(black) fcolor(white) lcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B1_Independence.gph"


graph bar, over(q23_3_a, label(labcolor("black") angle(vertical) labsize(vsmall))) bar(1, fcolor(gs11) lcolor(gs11)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(percent (%)) ytitle(, size(small) color(black)) ylabel(0(20)70, labsize(small) angle(horizontal) nogrid) by(, title(Support/oppose reforms to strengthen WHO: Authority, size(small) color(black)) note(`""', size(zero))) by(, graphregion(fcolor(white) lcolor(white)  ifcolor(white) ilcolor(white)) plotregion(lcolor(white))) by(exp_gr) subtitle(, size(small) color(black) fcolor(white) lcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B1_Authority.gph"




****** Figure B.2 Pre-treatment attitudes toward international cooperation in the full sample of politicians and among national parliamentarians exclusively

graph bar, over(q16, label(labcolor("black") angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs11) lcolor(gs11)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(percent (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Pre-treatment attitudes:  International cooperation a good instrument - All respondents, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B2_all.gph"




graph bar if riksdag==1, over(q16, label(labcolor("black") angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs11) lcolor(gs11)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(percent (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Pre-treatment attitudes:  International cooperation a good instrument - Parliamentarians, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B2_parliamentarians.gph"



*******  Figure B.3 Pre-treatment attitudes toward the WHO in the full sample of politicians and among national parliamentarians exclusively


graph bar, over(q18, label(labcolor("black") angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs11) lcolor(gs11)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(percent (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Pre-treatment attititudes: Confidence in WHO- All Respondents, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B3_all.gph"

graph bar if riksdag==1, over(q18, label(labcolor("black") angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs11) lcolor(gs11)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(percent (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Pre-treatment attititudes: Confidence in WHO - Parliamentarians, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B3_parliamentarians.gph"



 
**** Figure B4: Effect of public opinion on support for IO reforms (composite index) *******************************************



use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_ttest.dta", clear


twoway (scatter Index_mean treatment, mcolor(black) msize(medsmall) msymbol(circle)) (rspike Index_cilo Index_cihi treatment, lcolor(black)) if id>0 & id<3,  ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(medsmall) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(medsmall) angle(vertical) valuelabel) title(`"Composite index"', size(medium) color(black)) legend(off) xsize(2.5) ysize(5) plotregion(lcolor(black))

 graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B4.gph"

 
 
*** Figure B5 Effect of public opinion on support for IO reforms, by level of pre-treatment attitudes toward international cooperation ***********

*** Authority 

twoway (scatter Auth_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Auth_cilo Auth_cihi treatment, lcolor(black))if id>12 & id<19, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(small) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(small) angle(vertical) valuelabel) by(, title(`"Authority"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(small)lcolor(white)) xsize(5.5) ysize(4) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B5a.gph"

*** Resources

twoway (scatter Res_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Res_cilo Res_cihi treatment, lcolor(black))if id>12 & id<19, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(small) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(small) angle(vertical) valuelabel) by(, title(`"Resources"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(small)lcolor(white)) xsize(5.5) ysize(4) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B5b.gph"

*** Independence

twoway (scatter Indep_mean treatment, mcolor(black) msize(medlarge) msymbol(circle)) (rspike Indep_cilo Indep_cihi treatment, lcolor(black))if id>12 & id<19, ytitle(, size(zero)) yline(2 3 4, lwidth(thin) lpattern(solid) lcolor(gs8)) ylabel(2(1)4, labsize(small) angle(horizontal) valuelabel) xtitle(, size(zero))  xscale(range(0.5 2.5)) xlabel(1(1)2, labsize(small) angle(vertical) valuelabel) by(, title(`"Independence"', size(medsmall) color(black)) note(`""', size(zero))) by(, legend(off)) by(, graphregion(fcolor(white) lcolor(white))) by(subgroup, cols(3)) subtitle(, fcolor(white) size(small)lcolor(white)) xsize(5.5) ysize(4) plotregion(lcolor(black))

graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B5c.gph"

 
 
 
 
***** Figure B.6


use "/Users/thomassommerer/Dropbox/JoP/EffectsofLegitimacy_data.dta", clear
 

*** Public opinion against growing power of IO

graph bar, over(q29_1, label(labcolor("black") angle(horizontal) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(More difficult for government to get support in other fields of foreign policy, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B6a.gph"

graph bar, over(q29_2, label(labcolor("black") angle(horizontal) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(More difficult for government to get support on domestic issues, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B6b.gph"

graph bar, over(q29_3, label(labcolor("black") angle(horizontal) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(More difficult for government to get unity in parliament on foreign policy, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B6c.gph"

graph bar, over(q29_4, label(labcolor("black") angle(horizontal) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Government would loose support in polls, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B6d.gph"

**** Public opinion in favour of growing power of IO

graph bar, over(q31_1, label(labcolor("black") angle(horizontal) labsize(small))) bar(1, fcolor(gs12) lcolor(gs12)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(More difficult for government to get support in other fields of foreign policy, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(gs12)) xsize(4.5) ysize(5.5)
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B6e.gph"

graph bar, over(q31_2, label(labcolor("black") angle(horizontal) labsize(small))) bar(1, fcolor(gs12) lcolor(gs12)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(More difficult for government to get support on domestic issues, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(gs12))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B6f.gph"

graph bar, over(q31_3, label(labcolor("black") angle(horizontal) labsize(small))) bar(1, fcolor(gs12) lcolor(gs12)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(More difficult for government to get unity in parliament on foreign policy, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(gs12))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B6g.gph"

graph bar, over(q31_4, label(labcolor("black") angle(horizontal) labsize(small))) bar(1, fcolor(gs12) lcolor(gs12)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Government would loose support in polls, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(gs12))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B6h.gph"


 ***
 
 **** Figure B.7 

******* Consequences of going against public opinion: ....5 IOs

graph bar, over(q33_1, label(labcolor("black") angle(vertical) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Consequences of going against public opinion: EU, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B7_EU.gph"

graph bar, over(q33_2, label(labcolor("black") angle(vertical) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Consequences of going against public opinion: UN, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B7_UN.gph"

graph bar, over(q33_3, label(labcolor("black") angle(vertical) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Consequences of going against public opinion: IMF, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B7_IMF.gph"

graph bar, over(q33_4, label(labcolor("black") angle(vertical) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Consequences of going against public opinion: NATO, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B7_NATO.gph"

graph bar, over(q33_5, label(labcolor("black") angle(vertical) labsize(small))) bar(1, fcolor(black) lcolor(black)) blabel(bar, size(vsmall) color(black) format(%3.2f)) ytitle(Percentage (%)) ytitle(, size(small) color(black)) ylabel(0(10)60, labsize(small) angle(horizontal) nogrid) title(Consequences of going against public opinion: WHO, size(small) color(black)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(lcolor(black))
graph save "Graph" "/Users/thomassommerer/Dropbox/JoP/Fig_B7_WHO.gph"



 
 
 
******  Table B.1 Sample descriptives

tab polexp
tab age
tab sex
tab education
tab bcountry
tab politician_cat1822

******* Table B.2  Response time for survey questions (in seconds)

* Support or oppose reforms to strenghten WHO *

sum t_q*



*** Table B.3 Bivariate correlation IO basic capabilities (Pearsons r)

pwcorr q23_1_r q23_2 q23_3


 
